package Test11_08;
import java.util.*;

public class ListSetTest {
    public static void main(String[] args) {
        //List,Set中必须掌握的方法都要写个例子


        List list = new ArrayList();
        list.add(0, "cat");
        list.add("dog");
        list.add(1);
        list.add("fish");
        Object o =  list.get(2);
        System.out.println(o);
        for (int i = 0; i < list.size(); i++) {
            Object object = list.get(i);
            System.out.println(object);
        }
        System.out.println("-------------------------------------");

        Set<String> set = new HashSet<>();
        set.add("dog");
        set.add("cat");
        set.add("fish");

        System.out.println(set.size());//输出长度
        System.out.println(set);     //输出 但是不按顺序

        String[] object = set.toArray(new String[0]);

        System.out.println(object.length);//输出长度

        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            String str = it.next();
            System.out.println(str);
        }

    }
}
